package com.bytecub.gateway.mq.storage;

import com.bytecub.common.domain.gateway.mq.MQSendMessageBo;
import com.bytecub.common.enums.BCErrorEnum;
import com.bytecub.common.exception.BCGException;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * ByteCub.cn. Copyright (c) 2020-2021 All Rights Reserved.
 *
 * @author bytecub@163.com songbin
 * @version Id: ActiveStorage.java, v 0.1 2021-01-05 Exp $$
 */
public class PropertySetStorage {
    private static LinkedBlockingQueue<MQSendMessageBo> queue = new LinkedBlockingQueue<>();

    public static void push(MQSendMessageBo e) {
        queue.offer(e);
    }

    public static int size() {
        return queue.size();
    }

    public static MQSendMessageBo pop() {
        try {
            return queue.take();
        } catch (Exception e) {
            throw new BCGException(BCErrorEnum.INNER_EXCEPTION, "属性设备队列消费异常", e);
        }
    }
}
